$this->dbw = $this->getDB( DB_MASTER );
$this->dryrun = $this->hasOption( 'dry-run' );
if ( $this->dryrun ) {
- $GLOBALS['wgReadOnly'] = 'Dry run mode, image upgrades are suppressed';
+ MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode()
+ ->setReason( 'Dry run mode, image upgrades are suppressed' );
}
if ( $this->hasOption( 'missing' ) ) {
flush();
}
- function buildTable( $table, $key, $callback ) {
+ function buildTable( $table, $key, $queryInfo, $callback ) {
$count = $this->dbw->selectField( $table, 'count(*)', '', __METHOD__ );
$this->init( $count, $table );
$this->output( "Processing $table...\n" );
- $result = $this->getDB( DB_REPLICA )->select( $table, '*', [], __METHOD__ );
+ $result = $this->getDB( DB_REPLICA )->select(
+ $queryInfo['tables'], $queryInfo['fields'], [], __METHOD__, [], $queryInfo['joins']
+ );
foreach ( $result as $row ) {
$update = call_user_func( $callback, $row, null );
function buildImage() {
$callback = [ $this, 'imageCallback' ];
- $this->buildTable( 'image', 'img_name', $callback );
+ $this->buildTable( 'image', 'img_name', LocalFile::getQueryInfo(), $callback );
}
function imageCallback( $row, $copy ) {
}
function buildOldImage() {
- $this->buildTable( 'oldimage', 'oi_archive_name', [ $this, 'oldimageCallback' ] );
+ $this->buildTable( 'oldimage', 'oi_archive_name', OldLocalFile::getQueryInfo(),
+ [ $this, 'oldimageCallback' ] );
}
function oldimageCallback( $row, $copy ) {
}
}
-$maintClass = 'ImageBuilder';
+$maintClass = ImageBuilder::class;
require_once RUN_MAINTENANCE_IF_MAIN;